
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>如何配置 Nginx 实现 HTTPS 和 HTTP/2 支持？ - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>如何配置 Nginx 实现 HTTPS 和 HTTP/2 支持？ - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">在配置SSL/TLS时，针对开发环境和生产环境，文档推荐使用哪两种不同类型的证书？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">文档推荐在测试和开发环境中使用自签名证书（通过 openssl 生成），而在生产环境中应使用从受信任的证书颁发机构（CA）获取的正式证书。</div>
          </div>
          <div class="card-source">来源: 1. 获取 SSL/TLS 证书</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在Nginx配置文件中，启用HTTPS需要配置哪些最基本的SSL指令？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">启用HTTPS最基本的SSL指令包括：`ssl_certificate` 用于指定证书路径，`ssl_certificate_key` 用于指定私钥路径。此外，通常还会配置 `ssl_protocols` 来指定支持的TLS版本和 `ssl_ciphers` 来定义加密套件。</div>
          </div>
          <div class="card-source">来源: 2. 配置 Nginx 支持 HTTPS</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">如何在Nginx的HTTPS配置中启用HTTP/2支持？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">在Nginx的server配置块中，只需在`listen 443 ssl;`指令后添加`http2`选项即可，修改后的指令为 `listen 443 ssl http2;`。</div>
          </div>
          <div class="card-source">来源: 3. 配置 Nginx 启用 HTTP/2</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">文档中提到的HSTS头部（Strict-Transport-Security）有什么作用？如何在Nginx中添加它？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">HSTS (HTTP Strict Transport Security) 头部用于增加安全性，它会告知浏览器在指定时间内只能通过HTTPS访问该域名。在Nginx中，可以通过`add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;`指令来添加。</div>
          </div>
          <div class="card-source">来源: 2. 配置 Nginx 支持 HTTPS</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">什么是OCSP Stapling？它为什么能提高SSL性能和安全性？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">OCSP Stapling是一种性能优化机制。它通过在服务器端缓存证书在线状态协议（OCSP）的响应，并随证书一起发送给客户端，从而减少了客户端直接与证书颁发机构（CA）通信的需要，降低了延迟，进而提高了SSL性能和安全性。</div>
          </div>
          <div class="card-source">来源: 4. 可选配置和最佳实践</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在修改了Nginx配置文件以启用HTTPS或HTTP/2后，应该执行什么命令来使配置生效？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">在修改并保存Nginx配置文件后，应执行 `sudo nginx -s reload` 命令来平滑地重新加载配置，使新的设置生效。</div>
          </div>
          <div class="card-source">来源: 2. 配置 Nginx 支持 HTTPS</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
